﻿using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Windows;

namespace PefStudio.StartUp
{
    [Export(Contract, typeof(Bootstrapper))]
    public class WpfBootstrapper : Bootstrapper
    {
        public const string WindowCatalog = "Wpf";

        public WpfBootstrapper()
        {
            Instance = this;
            Description = "WpfBootstrapper";
        }

        public override void Run(bool runWithDefaultConfiguration)
        {
            var catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new DirectoryCatalog(WindowCatalog));

            Container = new CompositionContainer(catalog);
            Container.ComposeParts();

            var application = Container.GetExportedValue<Application>(MainWindowContract);
            application.Run();
            //System.Windows.Forms.Integration.WindowsFormsHost.EnableWindowsFormsInterop();
        }
    }
}
